package com.ebs.md.fxmonitor.marketmonitor.config;

/**
 * Revision Author:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/config/PulsingConfigImpl.java $
 *  $Revision: #12 $
 *  $DateTime: 2012/08/12 10:07:06 $
 *  $Change: 113123 $
 *  $Author: Arik.Sher $
 */

import org.apache.log4j.Logger;

import com.ebs.md.fxmonitor.marketmonitor.MarketMonitorConsts;
import com.ebsdr.fsp.ccc.configuration.IConfiguration;

public class PulsingConfigImpl implements IPulsingConfig, IConfigListener, MarketMonitorConsts
{
    final protected Logger logger = Logger.getLogger(getClass());
    final protected static String xsdPath = "/MonitoredMarketActivity/Pulsings/Pulsing";

    private int  numberOfDealsThreshold;
	private long timeFrameThreshold;
	private int  numberOfPulsesThreshold;
	private long lifeTimeThreshold;
	private int  priceLevelThreshold;


	@Override
	public String getName() {
		return BASIC_CONFIG_NAME;
	}

	@Override
	public void onConfig(IConfiguration configuration) 
	{
		numberOfDealsThreshold  = configuration.getInt (xsdPath + "/@numberOfDeals",  EVENT_PULSING_NUMBER_OF_DEALS_THRESHOLD);
		timeFrameThreshold      = configuration.getLong(xsdPath + "/@timeFrame",      EVENT_PULSING_TIME_FRAME_THRESHOLD);
		numberOfPulsesThreshold = configuration.getInt (xsdPath + "/@numberOfPulses", EVENT_PULSING_NUMBER_OF_PULSES_THRESHOLD);
		lifeTimeThreshold       = configuration.getLong(xsdPath + "/@interruptTime",  EVENT_PULSING_LIFE_TIME_THRESHOLD);
		priceLevelThreshold     = configuration.getInt (xsdPath + "/@priceLevel",     EVENT_PULSING_PRICE_LEVEL_THRESHOLD);
	
		logger.info( getConfigInfo() );
	}

	@Override
	public String getConfigInfo() {
		StringBuilder sb = new StringBuilder("PulsingConfigImpl: ");
		
		sb.append( " numberOfDeals: "  + numberOfDealsThreshold);
		sb.append(", numberOfPulses: " + numberOfPulsesThreshold);
		sb.append(", lifeTime: "       + lifeTimeThreshold);
		sb.append(", priceLevel: "     + priceLevelThreshold);
		sb.append(", timeFrame: "      + timeFrameThreshold);
		
		return sb.toString();
	}

	@Override
	public int getNumberOfDealsThreshold() {
		return numberOfDealsThreshold;
	}

	@Override
	public long getTimeFrameThreshold() {
		return timeFrameThreshold;
	}

	@Override
	public int getNumberOfPulsesThreshold() {
		return numberOfPulsesThreshold;
	}

	@Override
	public long getLifeTimeThreshold() {
		return lifeTimeThreshold;
	}

	@Override
	public int getPriceLevelThreshold() {
		return priceLevelThreshold;
	}
}
